#include "ThreadPool.hpp"
#include <iostream>

void print()
{
    cout << "aahhaha" << endl;
}

void test_thread()
{
    Task t;
    auto function = std::bind(&Task::doing, &t);
    Thread th("thread");
    th.start(function);
    sleep(1);
}

// main thread push task to queue, 'poolstart_th' thread call ThreadPool::start to handle tasks which poped from _task_queue
void test_threadpool()
{
    srand(time(nullptr));

    ThreadPool<Task>* tp = ThreadPool<Task>::CreateThreadPool();
    Thread poolstart_th("start pool", &ThreadPool<Task>::start, tp);

    Task t;
    sleep(2);
    for(int i = 0; i < 50; i++)
    {
        tp->enQueue(t);
    }
    sleep(10);
}

int main()
{
    //test_thread();
    test_threadpool();
    return 0;
}
